{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2765
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var
	cc,kk,tt,ls,i:longint;
	s:string;
	t:array[0..100] of string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(s);
s:=trim(s);
ls:=length(s);
i:=1;
while i<ls do begin
	inc(i);
	if (s[i]=s[i-1]) and (s[i]=' ') then begin
		delete(s,i,1);
		dec(i);
		ls:=length(S);
	end;
end;
cc:=1;
kk:=pos(' ',s);
while kk>0 do begin
	inc(cc);
	delete(s,1,kk);
	kk:=pos(' ',s);
end;
readln(s);
s:=trim(s);
ls:=length(s);
i:=1;
while i<ls do begin
	inc(i);
	if (s[i]=s[i-1]) and (s[i]=' ') then begin
		delete(s,i,1);
		dec(i);
		ls:=length(S);
	end;
end;
tt:=0;
kk:=pos(' ',s);
while kk>0 do begin
	inc(tt);
	t[tt]:=copy(s,1,kk-1);
	delete(s,1,kk);
	kk:=pos(' ',s);
end;
inc(tt);
t[tt]:=s;
write(t[(cc-1) mod tt+1]);
end.